﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for bussiness
/// </summary>
public class bussiness
{
    private datacessDB da;
    public bussiness()
    {
    }
    public bool checkNull(string text)
    {
        if (text == "")
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    public List<Ecard> getAllEcard()
    {
        da = new datacessDB();
        return da.getAllEcard();
    }
    public List<SentEcard> getAllSentEcard()
    {
        da = new datacessDB();
        return da.getAllSentEcard();
    }
    public List<listEmail> getAllListEmail()
    {
        da = new datacessDB();
        return da.getAllListEmail();
    }
    public List<TypeEcard> getAllTypeEcard()
    {
        da = new datacessDB();
        return da.getAllTypeEcard();
    }
    public List<Admins> getAllAdmin()
    {
        da = new datacessDB();
        return da.getAllAdmin();
    }
    public void insertCustomer(Customer c)
    {
        da = new datacessDB();
        da.insertcustomer(c);
    }
    public Boolean checkEmail(string Email)
    {
        da = new datacessDB();
        List<Customer> list = da.getAllCustomer();
        foreach (Customer c in list)
        {
            if (c.Email == Email)
            {
                return true;
            }
        }
        return false;
    }
    public Boolean checkUsername(string Username)
    {
        da = new datacessDB();
        List<Customer> list = da.getAllCustomer();
        foreach (Customer c in list)
        {
            if (c.Username == Username)
            {
                return true;
            }

        }
        return false;
    }
    public Customer checkLogin(string username, string password)
    {
        da = new datacessDB();
        List<Customer> list = da.getAllCustomer();
        foreach (Customer c in list)
        {
            if (c.Username == username && c.Password == password)
            {
                return c;
            }
        }
        return null;
    }
    public void insertSentEcard(SentEcard se)
    {
        da = new datacessDB();
        da.insertSentEcard(se);
    }
    public void insertListEmail(listEmail le)
    {
        da = new datacessDB();
        da.insertListEmail(le);
    }
    public void insertEcard(Ecard ecard)
    {
        da = new datacessDB();
        da.insertEcard(ecard);
    }
    public void insertFeedback(int customerId, string content)
    {
        da = new datacessDB();
        da.insertFeedback(customerId,content);
    }
    public int getSentEcardId(int customerId)
    {
        da = new datacessDB();
        return da.getSentEcardId(customerId);
    }
    public List<Customer> getAllCustomer()
    {
        da = new datacessDB();
        return da.getAllCustomer();
    }
    public Customer getCustomerById(int id)
    {
        da = new datacessDB();
        return getCustomerById(id);
    }
    public SentEcard getSentEcardById(int id)
    {
        da = new datacessDB();
        return da.getSentEcardById(id);
    }
    public LogSentMail getLogSentMailById(int id)
    {
        da = new datacessDB();
        return da.getLogSentMailById(id);
    }
    public Ecard getEcardById(int id)
    {
        da = new datacessDB();
        return da.getEcardById(id);
    }
    public void insertLogSentMail(LogSentMail log)
    {
        da = new datacessDB();
        da.insertLogSentMail(log);
    }
    public int getLogSentMailId(int customerId)
    {
        da = new datacessDB();
        return da.getLogSentMailId(customerId);
    }
    public DataTable getview_thongKeGiaoDichHoanThanhTheoCustomer()
    {
        da = new datacessDB();
        return da.getview_thongKeGiaoDichHoanThanhTheoCustomer();
    }
    public DataTable getLogSentMailByCustomerId(int customerId) 
    {
        da = new datacessDB();
        return da.getLogSentMailByCustomerId(customerId);
    }
    public DataTable getLogSentMailByCustomerIdByDay(int customerId)
    {
        da = new datacessDB();
        return da.getLogSentMailByCustomerIdByDay(customerId);
    }
    public DataTable getview_TypeEcardSentInMonth()
    {
        da = new datacessDB();
        return da.getview_TypeEcardSentInMonth();
    }
    public DataTable getview_EcardSentInMonth()
    {
        da = new datacessDB();
        return da.getview_EcardSentInMonth();
    }
    public DataTable getview_SubcribleDetail()
    {
        da = new datacessDB();
        return da.getview_SubcribleDetail();
    }
    public void updateCountEcard(int ecardId)
    {
        da = new datacessDB();
        da.updateCountEcard(ecardId);
    }
    public void updateEcard(int ecardId, string urlFlash, string ecardName, int typeEcardId)
    {
        da = new datacessDB();
        da.updateEcard(ecardId,urlFlash,ecardName,typeEcardId);
    }
    public void deleteTyeEcard(int TypeEcardId)
    {
        da = new datacessDB();
        da.deleteTyeEcard(TypeEcardId);
    }
    public void deleteEcard(int ecardId)
    {
        da = new datacessDB();
        da.deleteEcard(ecardId);
    }
    public void deleteFeedback(int feedbackId)
    {
        da = new datacessDB();
        da.deleteFeedback(feedbackId);
    }
    public void updateTypeEcard(int TypeEcardId, string typeCardName)
    {
        da = new datacessDB();
        da.updateTypeEcard(TypeEcardId,typeCardName);
    }
    public void insertTypeEcard(String nameTypeEcard)
    {
        da = new datacessDB();
        da.insertTypeEcard(nameTypeEcard);
    }
    public DataTable getView_Statistics_count()
    {
        da = new datacessDB();
       return da.getView_Statistics_count();
    }
    public int getCount_View_Statistics_count()
    {
        da = new datacessDB();
        return da.getCount_View_Statistics_count();
    }
    public int getSoLanGuiCardToDay()
    {
        da = new datacessDB();
        return da.getSoLanGuiCardToDay();
    }
    public DataTable getAllLogSentMail()
    {
        da = new datacessDB();
        return da.getAllLogSentMail();
    }
    public DataTable getViewDisplayEcard()
    {
        da = new datacessDB();
        return da.getViewDisplayEcard();
    }
    public List<LogSentMail> getLogSentMail()
    {
        da = new datacessDB();
        return da.getLogSentMail();
    }
    public DataTable getEcardByTypeId(int typeId)
    {
        da = new datacessDB();
        return da.getEcardByTypeId(typeId);
    }
    public DataTable getEcardNew() 
    {
        da = new datacessDB();
        return da.getEcardNew();
    }
    public DataTable getEcardMostSent()
    {
        da = new datacessDB();
        return da.getEcardMostSent();
    }
    public DataTable getview_feedback()
    {
        da = new datacessDB();
        return da.getview_feedback();
    }
    public DataTable getview_thongKeGiaoDichHoanThanhTheoCustomerByDay()
    {
        da = new datacessDB();
        return da.getview_thongKeGiaoDichHoanThanhTheoCustomerByDay();
    }
    public DataTable getview_StatisticTransactionByToday()
    {
        da = new datacessDB();
        return da.getview_StatisticTransactionByToday();
    }
    public int getview_numberOfSentMailInToday()
    {
        da = new datacessDB();
        return da.getview_numberOfSentMailInToday();
    }
}